#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1010;
int n,m,q;
vector<int> g[N];
bool vis[N],can[N][N],ctr[N][N];
int cnt[N];
void dfs1(int u,int x){
    if(u==x)return;
    if(vis[u])return;
    vis[u]=1;
    for(int v:g[u])dfs1(v,x);
}
vector<int> e[N];
int dfn[N],now,id[N],siz[N];
void dfs2(int u){
    id[dfn[u]=++now]=u;
    siz[u]=1;
    for(int v:e[u]){
        dfs2(v);
        siz[u]+=siz[v];
    }
}
int a[N];
bool cmp(int i,int j){
    return dfn[i]<dfn[j];
}
bool ban[N],flg[N];
int sum[N];
ll f[N][5];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    freopen("lodge.in","r",stdin);
    freopen("lodge.out","w",stdout);
    cin>>n>>m>>q;
    for(int i=1;i<=m;i++){
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)vis[j]=0;
        dfs1(i,0);
        for(int j=1;j<=n;j++)can[i][j]=vis[j];
        for(int j=1;j<=n;j++)vis[j]=0;
        dfs1(1,i);
        for(int j=1;j<=n;j++){
            if(vis[j])continue;
            ctr[i][j]=1;
            cnt[j]++;
        }
    }
    for(int i=2;i<=n;i++){
        int fa=1;
        for(int j=2;j<=n;j++)
            if(j!=i&&ctr[j][i]&&cnt[j]>cnt[fa])fa=j;
        e[fa].push_back(i);
    }
    dfs2(1);
    while(q--){
        int k,p;
        cin>>k>>p;
        for(int i=1;i<=p;i++)cin>>a[i];
        for(int i=1;i<=n;i++){
            ban[i]=0;
            flg[i]=0;
            for(int j=0;j<=k;j++)f[i][j]=0;
        }
        for(int i=1;i<=p;i++){
            flg[dfn[a[i]]]=1;
            for(int j=1;j<=n;j++)
                if(can[j][a[i]]&&!ctr[j][a[i]])
                    ban[j]=1;
        }
        for(int i=1;i<=n;i++)sum[i]=sum[i-1]+flg[i];
        f[0][0]=1;
        for(int i=1;i<=n;i++){
            if(!flg[i])for(int j=0;j<=k;j++)f[i][j]+=f[i-1][j];
            if(!ban[id[i]]&&sum[i+siz[id[i]]-1]>sum[i-1])
                for(int j=1;j<=k;j++)f[i+siz[id[i]]-1][j]+=f[i-1][j-1];
        }
        cout<<f[n][k]<<'\n';
    }
    return 0;
}
